package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkSpaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.LocalTime;

@RestController
@RequestMapping("/admin/workspace")
@Api(tags = "工作台相关接口")
@Slf4j
public class WorkSpaceController {
    @Autowired
    private WorkSpaceService workSpaceService;
    /**
     * 接口描述：查询今日运营数据
     * 请求参数：无
     * 请求参数类型：无
     * 返回类型：Result<BusinessDataVO>
     * 路径：/admin/workspace/businessData
     * 请求方式：GET
     */
    @GetMapping("/businessData")
    public Result<BusinessDataVO> businessData() {
        LocalDateTime end =  LocalDateTime.now().with(LocalTime.MAX);
        //获取今日开始时间
        LocalDateTime begin =  LocalDateTime.now().with(LocalTime.MIN);
        BusinessDataVO businessDataVO = workSpaceService.businessData( begin, end);
        log.info("查询今日运营数据{}",businessDataVO.toString());
        return Result.success(businessDataVO);
    }
    /**
     * 接口描述：查询套餐总览
     * 请求参数：无
     * 请求参数类型：无
     * 返回类型：Result<SetmealOverViewVO>
     * 路径：/admin/workspace/overviewSetmeals
     * 请求方式：GET
     */
    @GetMapping("/overviewSetmeals")
    public Result<SetmealOverViewVO> overviewSetmeals() {
        SetmealOverViewVO setmealOverViewVO = workSpaceService.overviewSetmeals();
        log.info("查询套餐总览{}",setmealOverViewVO.toString());
        return Result.success(setmealOverViewVO);
    }
    /**
     * 接口描述：查询菜品总览
     * 请求参数：无
     * 请求参数类型：无
     * 返回类型：Result<DishOverViewVO>
     * 路径：/admin/workspace/overviewDishes
     * 请求方式：GET
     */
    @GetMapping("/overviewDishes")
    public Result<DishOverViewVO> overviewDishes() {
        DishOverViewVO dishOverViewVO = workSpaceService.overviewDishes();
        return Result.success(dishOverViewVO);
    }
    /**
     * 接口描述：查询订单管理数据
     * 请求参数：无
     * 请求参数类型：无
     * 返回类型：Result<OrderOverViewVO>
     * 路径：/admin/workspace/overviewOrders
     * 请求方式：GET
     */
    @GetMapping("/overviewOrders")
    public Result<OrderOverViewVO> overviewOrders() {
        OrderOverViewVO orderOverViewVO = workSpaceService.overviewOrders();
        return Result.success(orderOverViewVO);
    }
}
